package com.example.ywj.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;

import java.util.ArrayList;

public class listViewActivity extends AppCompatActivity {
    private ListView listView;
    // 数据
    private ArrayList<Apply> applys = new ArrayList<>();
    private ApplyAdapter adapter;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_view);
        initView();
    }
    public void initView(){
        listView = findViewById(R.id.listview);
        initData();
        adapter = new ApplyAdapter(applys);
        listView.setAdapter(adapter);

    }
    public void initData(){
        int[] imgs = new int[]{R.drawable.jd,R.drawable.qq,R.drawable.sina,R.drawable.tmall,
                R.drawable.uc,R.drawable.qq_dizhu,R.drawable.weixin};
        String[] names = new String[]{"京东","QQ","新浪","天猫","UC","斗地主","微信"};

        for (int i = 0;i<imgs.length;i++){
            Apply apply = new Apply(imgs[i],names[i]);
            applys.add(apply);
        }
    }
}
